﻿<commonbase:LayoutAwarePage
    x:Class="Icinetic.FeedCategorySample.MainPage"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Icinetic.FeedCategorySample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:converters="using:Icinetic.FeedCategorySample.Common.Converters"  
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:commonbase="using:Icinetic.FeedCategorySample.Common.Base"
    xmlns:common="using:Icinetic.FeedCategorySample.Common"
    mc:Ignorable="d">

    <Page.Resources>
        <CollectionViewSource
                x:Name="CategoryitemsViewSource"
                Source="{Binding CategoryList}"
                IsSourceGrouped="true"
                ItemsPath="Articles"
                />
        <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </Page.Resources>

    <Page.TopAppBar>
        <AppBar x:Name="appBarZoomIn" Style="{StaticResource TopAppBarStyle}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left">
                    <Button x:Name="MainButton" Click="MainButton_Click" Style="{StaticResource MainAppBarButtonStyle}"/>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.TopAppBar>

    <Grid Background="White" >
        <ProgressBar x:Name="progress"
            IsIndeterminate="True" 
            HorizontalAlignment="Stretch" 
            Foreground="{StaticResource ApplicationColor}" 
            Background="Transparent"
            Style="{StaticResource ProgressBarStyle}"
            Canvas.ZIndex="1"
            Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"
            />
        <Grid x:Name="backgroundImage" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <Image  Source="/Assets/fondo.png" Stretch="Fill"/>
        </Grid>
        <Grid x:Name="backgroundImagePortrait" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Visibility="Collapsed">
            <Image  Source="/Assets/FondoPortrait.png" VerticalAlignment="Bottom" />
            <Image  Source="/Assets/FondoPortrait-logo.png" VerticalAlignment="Top" Margin="83,0,0,0" />
        </Grid>
        <Image x:Name="backgroundImageSnapped" Source="/Assets/Fondo-snap.png" VerticalAlignment="Top" HorizontalAlignment="Stretch" Stretch="Uniform" Visibility="Collapsed" />

        <Grid Height="100" VerticalAlignment="Top">
            <TextBlock x:Name="title" Text="{Binding Title}" Style="{StaticResource HeaderTextStyle}" VerticalAlignment="Bottom" Margin="123,0,0,0"></TextBlock>
        </Grid>

        <local:MenuControl x:Name="menuControl" Loaded="StartLayoutUpdates" VerticalAlignment="Stretch"/>

        <local:MenuSnappedControl x:Name="snappedControl" VerticalAlignment="Stretch" Visibility="Collapsed"/>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundImagePortrait" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundImage" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundImageSnapped" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="title" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="103,0,0,0"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundImageSnapped" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="snappedControl" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="menuControl" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="title" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundImage" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundImagePortrait" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</commonbase:LayoutAwarePage>
